package designPattern.mvc
{
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;

	public class View implements IView
	{
		private var model:IModel;
		private var control:IControl;
		public function View(m:IModel, c:IControl, target:Stage)
		{
			model = m;
			control = c;
			
			model.addEventListener(Event.CHANGE, update);
			target.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressHandler);	
		}
		
		private function update(evt:Event):void
		{
			trace(model.getKey());	
			MVCMainClass.alert(model.getKey().toString());
		}
		
		private function onKeyPressHandler(evt:KeyboardEvent):void
		{
			control.keyPressHandler(evt);	
		}
	}
}